# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php83-pecl-swoole
_extname=swoole
pkgver=5.1.1
pkgrel=0
pkgdesc="Event-driven asynchronous and concurrent networking engine with high performance for PHP 8.3 - PECL"
url="https://pecl.php.net/package/swoole"
arch="all !x86 !armv7 !armhf" # no 32-bit support
license="Apache-2.0"
_phpv=83
_php=php$_phpv
depends="$_php-curl $_php-mysqlnd $_php-openssl $_php-pdo $_php-sockets"
makedepends="$_php-dev
	c-ares-dev
	curl-dev
	libpq-dev
	nghttp2-dev
	openssl-dev
	sqlite-dev
	"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz"
builddir="$srcdir"/$_extname-$pkgver
subpackages="$pkgname-dev"

case "$CARCH" in
	ppc64le|s390x) makedepends="$makedepends libucontext-dev" ;;
esac

build() {
	case "$CARCH" in
		ppc64le|s390x) export LDFLAGS="$LDFLAGS -lucontext" ;;
	esac
	phpize$_phpv
	./configure --prefix=/usr \
		--with-php-config=php-config$_phpv \
		--with-nghttp2_dir=/usr \
		--enable-mysqlnd \
		--enable-openssl --with-openssl-dir=/usr \
		--enable-sockets \
		--enable-swoole-curl \
		--enable-swoole-pgsql \
		--enable-swoole-sqlite \
		--enable-brotli --with-brotli-dir=/usr \
		--enable-cares
	make
}

check() {
	# needs extra services to test all suite
	$_php -d extension=modules/swoole.so --ri swoole
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/$_php/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/50_$_extname.ini
}

sha512sums="
ac5f6a737a42123417de33219f56c1ce95b7217d1e66d5021cb6f0126c9fead7917aa38f577330e3391e7780e3a2117b53dff72069680c1c3d0780b52d8d1f61  php-pecl-swoole-5.1.1.tgz
"
